
import { Column, Entity, PrimaryColumn, ManyToOne, JoinColumn } from 'typeorm';
import { TeacherEntity } from './teacher.entity';
import { TeamEntity } from './team.entity';
import { GroupEntity } from './group.entity';

@Entity('teacher_volunteer_team', {
    comment: '教师志愿表',
    schema: "public"
})
export class TeacherVolunteerTeamEntity {
	@PrimaryColumn({ type: 'integer', name: 'group_id', comment: '分组id' })
	groupId: number;

	@PrimaryColumn({ type: 'integer', name: 'teacher_id', comment: '教师id' })
	teacherId: number;

	@PrimaryColumn({ type: 'integer', name: 'team_id', comment: '队伍id' })
	teamId: number;

	@Column({ type: 'integer', name: 'sort', default: null, comment: '志愿次序' })
	sort: number;

	@ManyToOne(() => GroupEntity, (group) => group.teacherVolunteers)
	@JoinColumn({ name: 'group_id', referencedColumnName: 'groupId' })
	group: GroupEntity;

	@ManyToOne(() => TeacherEntity, (teacher) => teacher.teacherVolunteers)
	@JoinColumn({ name: 'teacher_id', referencedColumnName: 'teacherId' })
	teacher: TeacherEntity;

	@ManyToOne(() => TeamEntity, (team) => team.teacherVolunteers)
	@JoinColumn({ name: 'team_id', referencedColumnName: 'teamId' })
	team: TeamEntity;
}
